﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using System.Xml.Serialization;
using System.IO;
using Wix.Aura.Common;
using System.Xml;
using Wix.Aura.Common.CustomTypes;

namespace Wix.Aura.UnitTests.Common {

    [TestFixture]
    public class SimpleWixProductSerialization : XmlAssertionBase {
		[SetUp]
		public void SetUp() { 
			testProductId = Guid.NewGuid();
			testProductLanguage = Language.Default;
			testProductManufacturer = "Manufacturious";
			testProductName = "Test Product";
			testProductVersion = "9.0.10023.142";
			testProduct = new Product(testProductId, testProductLanguage, testProductManufacturer, testProductName, testProductVersion, new Package(Guid.Empty));
		}

		private Product testProduct;
		private Guid testProductId;
		private Language testProductLanguage;
		private string testProductManufacturer;
		private string testProductName;
		private string testProductVersion;

		[Test]
		public void SerializeProjectWithRequiredVersion() {
			string xml = string.Format(
@"<?xml version=""1.0"" encoding=""utf-8""?>
<Wix requiredversion=""3.5.2.7"" xmlns=""http://schemas.microsoft.com/Wix/2006/wi"">
	<Product Id=""{0}"" Language=""{1}"" Manufacturer=""{2}"" Name=""{3}"" Version=""{4}"">
		<Package Id=""00000000-0000-0000-0000-000000000000"" />
	</Product>
</Wix>", testProductId.ToString().ToUpper(), ((int)testProductLanguage).ToString(), testProductManufacturer, testProductName, testProductVersion);

			WixProject project = new WixProject(testProduct);
			project.RequiredVersion = new VersionType(3, 5, 2, 7);
			Assertion(xml, project);
		}
    }
}
